import 'package:flutter/material.dart';
import 'package:flutter_app/components/no-record.dart';
import 'package:flutter_app/components/layout.dart';
import 'package:flutter_app/generated/l10n.dart';

class FixedRecordPage extends StatefulWidget {
  @override
  _FixedRecordPageState createState() => _FixedRecordPageState();
}

Widget RowItem(String title, String value) {
  return Expanded(
    child: Column(
      children: [
        Text(
          title,
          style: TextStyle(color: Colors.white54),
        ),
        Text(
          value,
          style: TextStyle(color: Colors.white),
        )
      ],
    ),
  );
}

class _FixedRecordPageState extends State<FixedRecordPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  List tabs = List(3);

  @override
  void initState() {
    super.initState();
    // 创建Controller
    _tabController = TabController(length: tabs.length, vsync: this);
  }

  Widget build(BuildContext context) {
    tabs = [S.of(context).all, S.of(context).hold, "已回款"];
    return Scaffold(
      appBar: AppBar(
        brightness: Brightness.dark,
        backgroundColor: Colors.blueAccent[400],
        elevation: 0,
        //固收投资
        title: HeadTitle(S.of(context).fixed_invest),
        centerTitle: true,
      ),
      body: Column(
        children: [
          Container(
            color: Colors.blueAccent[400],
            child: Column(
              children: [
                SizedBox(
                  height: 20,
                ),
                Center(
                  child: Column(
                    children: [
                      Text(
                        '持有资产估值',
                        style: TextStyle(color: Colors.white54),
                      ),
                      Text(
                        '\$0.00',
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.bold,
                            fontSize: 26),
                      )
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 20.0),
                  child: Row(
                    children: [
                      RowItem('每日收益', '+\$0.00'),
                      RowItem('累计收益', '+\$0.00'),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Topradius(
            bgColor: Colors.blueAccent,
            child: TabBar(
                //生成Tab菜单
                controller: _tabController,
                labelColor: Colors.blueAccent,
                unselectedLabelColor: Colors.grey,
                indicatorColor: Colors.blueAccent,
                indicatorSize: TabBarIndicatorSize.label,
                indicatorWeight: 1.0,
                tabs: tabs.map((e) => Tab(text: e)).toList()),
          ),
          Expanded(
              child: RefreshIndicator(
            onRefresh: () async {},
            child: NoRecord(),
          ))
        ],
      ),
    );
  }
}
